<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<html>
	<head>
		<title>请假单</title>
		<%@ include file="/common/meta.jsp"%>
		<%@ include file="/common/jquery-ui-inc.jsp"%>
		<script>
<%--user1用户使用时待办任务--%>
$(function() {
	$('#lockList').datagrid( {
		title : '待办任务列表',
		url : '${ctx}/flow/business/flow-leave!leaveData.action',
		loadMsg : '数据载入中，请稍后……',
		nowrap : false,
		collapsible : false,
		fitColumns : true,
		pagination : true,
		singleSelect : true,
		rownumbers : true,
		remoteSort : false,
		pageList : [ 15, 30, 50 ],
		idField : 'processinsid',
		columns : [ [ {
			field : 'processinsid',
			title : '实例ID',
			width : 220
		}, {
			field : 'deploymentid',
			title : '流程ID',
			width : 120
		}, {
			field : 'userename',
			title : '用户账号',
			width : 100
		}, {
			field : 'daynum',
			title : '请假天数',
			width : 100
		},  {
			field : 'reason',
			title : '请假理由',
			width : 200
		}, {
			title : '操作',
			field : 'cz',
			width : 280,
			formatter:function(value,row,index){
				var manager = '<a href="javascript:viewProcessPic(\''+row.processinsid+'\')">查看流程图</a>';
			 	return manager;
			}
		}] ],
		toolbar : [ 
		            {
		 				text : '填写请假单',
		 				iconCls : 'icon-add',
		 				handler : function() {
		 					leaveProcess();
		 				}
		 			}

		 		  ]
	});
	
	$("#leaveForm").form({
		url:"${ctx}/flow/business/flow-leave!start.action",
		success:function(data){
			$('#leaveWin').window('close');
			var d = $.parseJSON(data);
			$.messager.alert("提示",d.msg);
			reload();
			
		}
	});
});
	  
//发布业务流程
function leaveProcess(){
	$('#leaveWin').window('open');
}
	function danBanTask(id) {
		$("#banbantaskId").val(id);
		$('#taskWin').window('open');
	}
	  
	//查看任务
	function viewTask(url,id) {
		$("#taskId").val(id);
		$("#url").val(url);
		viewTaskOk();
	}
	//查看任务
	function viewTaskOk() {
		var taskId = $("#taskId").val();
		var url = $("#url").val();
		url = "leave1.jsp"
		var params = $("#params").val();
		var taskAssignee = $("#taskAssignee").val();
		var urlStr = "${ctx}/flow/"+url+"?taskId="+taskId; 
		url = urlStr;
		if(taskAssignee != '')
			url = url + "&userId="+taskAssignee;
		if(params != '')	
			url = url + "&"+params;
		
		window.location.href=url;
	}
	

	//查看流程图
	function viewProcessPic(id){
		var url = "${ctx}/flow/core/flow-view-pic.action?processInsId="+id;
		$("#viewPicFrame").attr("src",url);
		$('#viewPicWin').window('open');
	}

	function closeAddWin(){
		$('#lockAddWin').window('close');
	}
	
	function closeTaskWin(){
		$('#taskWin').window('close');
	}

	function reload(){
		$('#lockList').datagrid('reload');
	}

		
	function lockQuery(){	
		var taskParas = $('#taskParas').val();
		$('#lockList').datagrid('options').url="${ctx}/flow/core/flow-business-task!taskPersonData.action";
	    var queryParams = $('#lockList').datagrid('options').queryParams;
	      queryParams.taskAssignee = $('#taskAssignee').val();
	      reload(); 
	  }
	function clearQuery(){					
	    $('#taskAssignee').val('');
	  }  
	  
			
	</script>
	</head>

	<body>
		<table id="lockList"></table>
		<div id="leaveWin" class="easyui-window" title="填写请假单"
			style="padding: 5px; width:400px; height:300px;"
			iconCls="icon-search" closed="true" maximizable="false"
			minimizable="false" collapsible="false">
			<fieldset>
				<legend>填写请假单</legend>
				<form action="" method="post" id="leaveForm">
					<input type="hidden" name="definitionId" value="${definitionId}">
					<input type="hidden" name="deptId" value="ZBX1">
					<br>
					申请人&nbsp;&nbsp;&nbsp;
						<input type="text" name="owner" value="${loginUser.userCname}" readonly="readonly">
					</br>
					
					<br>
						<div>请假时间&nbsp;&nbsp;&nbsp;<input type="text" name="dayNum" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"></div>  
					</br>
					
					<div>
						请假原因&nbsp;&nbsp;&nbsp; 
						<textarea name="reason"> </textarea>
					</div>
					<input id="btnSubmit" type="submit" value="提交">
				</form>
			</fieldset>
		</div>
		<div id="lockAddWin" class="easyui-window" title="任务"
			style="padding: 5px; width: 330px; height:250px;"
			iconCls="icon-search" closed="true" maximizable="false"
			minimizable="false" collapsible="false" modal="true">
			<div class="easyui-layout" fit="true" border="false">
				<div region="center">
				<table class="datagrid-body">
					<tr>
						<td class="datagrid-header">
							序号
						</td>
						<td>
							<input name="taskId" id="taskId" type="text" readonly="readonly"/>
						</td>
					</tr>
					<tr>
						<td class="datagrid-header">
							表单地址
						</td>
						<td>
							<input name="url" id="url" type="text" readonly="readonly"/>
						</td>
					</tr>
					<tr>
						<td class="datagrid-header">
							任务执行参数
						</td>
						<td>
							<input name="params" id="params" value=""/>
						</td>
					</tr>
					<tr>
						<td>
							<a class="easyui-linkbutton" iconCls="icon-search"
								onclick="viewTaskOk();">查看任务</a>
						</td>
						<td>
							<a class="easyui-linkbutton" iconCls="" onclick="closeAddWin();">取消</a>
						</td>
					</tr>
				</table>
				</div>
			</div>
		</div>
		
		
		<div id="taskWin" class="easyui-window" title="代办任务"
			style="padding: 5px; width: 330px; height:150px;"
			iconCls="icon-search" closed="true" maximizable="false"
			minimizable="false" collapsible="false" modal="true">
			<div class="easyui-layout" fit="true" border="false">
				<div region="center">
				<table class="datagrid-body">
					<tr>
						<td class="datagrid-header">
							序号
						</td> 
						<td>
							<input name="banbantaskId" id="banbantaskId" readonly="readonly"/>
						</td>
					</tr>
					<tr>
						<td class="datagrid-header">
							代办人
						</td>
						<td>
							<input name="agentParams" id="agentParams" value=""/>
						</td>
					</tr>
					<tr>
						<td>
							<a class="easyui-linkbutton" iconCls="icon-search"
								onclick="danbanTaskOk();">分配任务</a>
						</td>
						<td>
							<a class="easyui-linkbutton" iconCls="" onclick="closeTaskWin();">取消</a>
						</td>
					</tr>
				</table>
				</div>
			</div>
		</div>
		
		<div id="viewPicWin" class="easyui-window" title="查看流程图"
			style="padding: 5px; width: 1000px; height: 600;"
			iconCls="icon-search" closed="true" maximizable="false"
			minimizable="false" collapsible="false">
			<iframe frameborder="0" id="viewPicFrame" height="100%" width="100%"
				scrolling="yes" frameborder="0"></iframe>
		</div>
	</body>
</html>